package org.lovebugs.dkm;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

import org.lovebugs.common.BaseActivity;
import org.lovebugs.web.Web;

import android.os.Message;
import android.webkit.WebSettings;
import android.widget.ProgressBar;


public class ArticleWebActivity extends BaseActivity {

	public static final int UPDATE_PROGRESS = 0;
	private Web web;

	private ProgressBar bar;
	@Override
	protected int getLayout() {
		// TODO Auto-generated method stub
		return R.layout.article;
	}

	@Override
	protected void handleMessage(Message msg) {
		// TODO Auto-generated method stub
		switch(msg.what) {
		case UPDATE_PROGRESS:
			this.bar.setProgress(msg.arg1);
			break;
		}
	}

	@Override
	protected void initComponent() {
		// TODO Auto-generated method stub
		this.bar = (ProgressBar)this.findViewById(R.id_web.pbar);
		this.web = (Web)this.findViewById(R.id.article_web);
//		this.web.loadUrl("http://www.apkbus.com/mtAndroid/");
		InputStream iStream = this.getResources().openRawResource(R.raw.fd);
		BufferedReader bReader = new BufferedReader(new InputStreamReader(iStream));
		StringBuffer sBuffer = new StringBuffer();
		String read;
		try {
			while(null!=(read = bReader.readLine())) {
				sBuffer.append(read);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        this.web.loadDataWithBaseURL(null, sBuffer.toString(), "text/html", "UTF-8", null);
	}
	

}
